<template>
  <a-drawer width="640" placement="right" :closable="false" v-if="open" v-model:visible="open">
    <a-collapse v-model:activeKey="activeKey" ghost>
      <a-collapse-panel key="1" header="钻井基础数据">
        <div>
          <a-descriptions bordered :column="4" size="middle">
            <a-descriptions-item label="地理位置" :span="4">{{ form?.wellLocation || "---" }}</a-descriptions-item>
            <a-descriptions-item label="构造位置" :span="4">{{ form?.wellConstruct || "---" }}</a-descriptions-item>
            <a-descriptions-item label="开钻日期" :span="2">{{ form?.drillingDate || "---" }}</a-descriptions-item>
            <a-descriptions-item label="完钻日期" :span="2">{{ form?.completionDate || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="井号" :span="2">{{ form?.wellId || "---" }}</a-descriptions-item>
            <a-descriptions-item label="钻井队号" :span="2">{{ form?.teamNumber || "---" }}</a-descriptions-item>
            <a-descriptions-item label="井别" :span="2">{{ form?.wellCategory || "---" }}</a-descriptions-item>
            <a-descriptions-item label="井型" :span="2">{{ form?.wellType || "---" }}</a-descriptions-item>
            <a-descriptions-item label="井深(m)" :span="2"> {{ form?.operatingWellDepth || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="钻井液类型" :span="2">{{ form?.fluidType || "---" }}</a-descriptions-item>
            <a-descriptions-item label="钻井液密度(g/cm^3)" :span="2">{{ form?.fluidDensity || "---" }}</a-descriptions-item>
            <a-descriptions-item label="钻井液粘度(s)" :span="2">{{ form?.viscosity || "---" }}</a-descriptions-item>
            <a-descriptions-item label="钻井设备" :span="2">{{ form?.drillingEquipment || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="钻具扣型" :span="4">
              <a-descriptions-item v-for="(typeItem, index) in form.drillToolType" :key="index">
                <p>国标: {{ typeItem?.nationalStandard || "---" }}</p>
              </a-descriptions-item>
            </a-descriptions-item>
            <a-descriptions-item label="钻头程序(mm×m)" :span="4">
              <a-descriptions-item v-for="(drillItem, index) in form?.drillList" :key="index">
                <p>钻头名称: {{ drillItem?.name || "---" }}</p>
                <p>外径: {{ drillItem?.outerDiameter || "---" }}</p>
                <p>深度: {{ drillItem?.deep || "---" }}</p>
              </a-descriptions-item>
            </a-descriptions-item>
            <a-descriptions-item label="套管程序(mm×m)" :span="4">
              <a-descriptions-item v-for="(casingItem, index) in form?.casingList" :key="index">
                <p>钻头名称: {{ casingItem?.name || "---" }}</p>
                <p>外径: {{ casingItem?.outerDiameter || "---" }}</p>
                <p>深度: {{ casingItem?.deep || "---" }}</p>
              </a-descriptions-item>
            </a-descriptions-item>
          </a-descriptions>
        </div>
      </a-collapse-panel>
      <a-collapse-panel key="2" header="井身结构数据">
        <div>
          <a-descriptions bordered :column="4" size="middle" :label-style="{ width: '190px' }">
            <a-descriptions-item label="造斜点深(m)" :span="2">{{ form?.obliquePointDeep || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="最大井斜（°）/深度" :span="2">{{ form?.maxDeviation || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="卡点测深(m)" :span="2">{{ form?.stuckPointsDeep || "---" }}
            </a-descriptions-item>
            <a-descriptions-item label="卡点井斜 （°）" :span="2"> {{ form?.pointWellSlope || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="卡点方位（°）" :span="2"> {{ form?.pointWellLocation || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="卡点狗腿度 (°/30m)" :span="2">{{ form?.stuckPointsDoglegDegree || "---" }}
            </a-descriptions-item>
          </a-descriptions>
        </div>
      </a-collapse-panel>
      <a-collapse-panel key="3" header="测井数据">
        <div>
          <a-descriptions bordered size="middle" :column="4" :label-style="{ width: '170px' }">
            <a-descriptions-item label="测井小队" :span="2">{{ form?.constructionTeam ||
              "---" }}</a-descriptions-item>
            <a-descriptions-item label="仪器类别" :span="2">{{ form?.instrumentType || "---"
            }}</a-descriptions-item>
            <a-descriptions-item label="仪器弱点位置" :span="2">{{ form?.instrumentWeaknesses ||
              "---" }}</a-descriptions-item>
            <a-descriptions-item label="抓捞仪器位置" :span="2"> {{ form?.salvagePosition || "---" }}
            </a-descriptions-item>
            <a-descriptions-item label="电缆型号" :span="2">{{ form.cable?.cableId || "---" }}</a-descriptions-item>
            <a-descriptions-item label="电缆投产日期" :span="2">{{ form?.putDate || "---" }}</a-descriptions-item>
            <a-descriptions-item label="弱点设置（t）" :span="2">{{ form?.weaknessSettings || "---" }}
            </a-descriptions-item>
            <a-descriptions-item label="电缆接头" :span="2">{{ form?.cableGlands || "---" }}</a-descriptions-item>
            <a-descriptions-item label="拉断力(kN)" :span="2">{{ form.cable?.breakingForce || "---" }}</a-descriptions-item>
            <a-descriptions-item label="拉力测试日期" :span="2">{{ form?.tensileTestDate ||
              "---" }}</a-descriptions-item>
            <a-descriptions-item label="作业空间" :span="2">{{ form?.workSpace || "---" }}</a-descriptions-item>
            <a-descriptions-item label="遇卡仪器" :span="2">{{ form?.stuckInstruments || "---" }}</a-descriptions-item>
            <a-descriptions-item label="遇卡描述" :span="2">{{ form?.description || "---" }}</a-descriptions-item>
            <a-descriptions-item label="电缆张力" :span="2">{{ form?.tension || "---" }}</a-descriptions-item>
            <a-descriptions-item label="卡点" :span="2">{{ form?.points || "---" }}</a-descriptions-item>
            <a-descriptions-item label="遇卡原因" :span="2">{{ form?.cause || "---" }}</a-descriptions-item>
          </a-descriptions>
        </div>
      </a-collapse-panel>
      <a-collapse-panel key="4" header="井落鱼结构表">
        <div>
          <a-table :columns="toolColumns" :data-source="form.wellfallFishList" :scroll="{ x: 1000 }">
            <template #bodyCell="{ column, text }"> </template>
          </a-table>
        </div>
      </a-collapse-panel>
      <a-collapse-panel key="5" header="井下仪器状态分析">
        <div>
          （1）测井队校深后，仪器底部深度 {{ form?.instrumentBottomDepth || "---" }}米，仪器顶部位置在 {{ form?.instrumentTopPosition || "---"
          }}米；<br />
          （2）初步判断遇卡原因为{{ form?.causeAnalysis || "---" }}；<br />
          （3）最小抗拉伸力为 {{ form?.minTensileResistance || "---" }}，最小抗压缩力为 {{ form?.minCompressiveForces || "---" }}；<br />
          （4）仪器已断电，仪器腿已收回。<br />
        </div>
      </a-collapse-panel>
      <a-collapse-panel key="7" header="打捞工具准备">
        <div>
          <a-table :columns="toolReadyColumns" :data-source="form.salvageToolList">
            <template #bodyCell="{ column, text }"> </template>
          </a-table>
        </div>
      </a-collapse-panel>
    </a-collapse>
  </a-drawer>
</template>
<script setup>
const props = defineProps({
  reportId: {
    type: String,
  },
  solutionDetail: {
    type: Object,
  },
});
const form = ref({});
const open = ref(false)
const activeKey = ref(['1']);
// 井落鱼结构表
const toolColumns = ref([
  {
    title: "仪器类型",
    dataIndex: "instrumentType",
    key: "instrumentType",
  },
  {
    title: "长度（m）",
    dataIndex: "length",
    key: "length",
  },
  {
    title: "外径（mm）",
    dataIndex: "outsideDiameter",
    key: "outsideDiameter",
  },
  {
    title: "耐温 小时（℃）(h)",
    dataIndex: "temperatureResistanters",
    key: "temperatureResistanters",
  },
  {
    title: "耐压(Mpa)",
    dataIndex: "pressureResistant",
    key: "pressureResistant",
  },
  {
    title: "质量（kg）",
    dataIndex: "quality",
    key: "quality",
  },
  {
    title: "抗拉伸力（lbf）",
    dataIndex: "tensileResistance",
    key: "tensileResistance",
  },
  {
    title: "抗压缩力（lbf）",
    dataIndex: "antiCompression",
    key: "antiCompression",
  },
]);
// 作业设备表
const workColumns = ref([
  {
    title: "类别",
    dataIndex: "name",
    key: "name",
  },
  {
    title: "配套装备名称",
    dataIndex: "name",
    key: "name",
  },
  {
    title: "数量",
    dataIndex: "name",
    key: "name",
  },
  {
    title: "规格型号",
    dataIndex: "name",
    key: "name",
  },
  {
    title: "提供单位",
    dataIndex: "name",
    key: "name",
  }])
// 打捞工具准备
const toolReadyColumns = ref([
  {
    title: "名称",
    dataIndex: "name",
    key: "name",
  },
  {
    title: "数量",
    dataIndex: "number",
    key: "number",
  },
  {
    title: "技术尺寸",
    dataIndex: "size",
    key: "size",
  },
  {
    title: "提供单位",
    dataIndex: "unit",
    key: "unit",
  }
])
// 监听数据变化
watch(() => props.solutionDetail, (newV) => {
  console.log("props.solutionDetail", newV);
  getSolution();
}, { deep: true });

// 获取施工方案信息
function getSolution() {
  form.value = props.solutionDetail
  console.log("form.value", form.value);
}
getSolution();

function openDrawer() {
  open.value = true;
}
defineExpose({
  openDrawer: openDrawer
})
</script>
